package com.kk.single;

/**
 * 饿汉式
 * 静态常量
 *
 * @author 王志强
 * @date 2021-12-09
 */
public class Singleton0 {

    private static final Singleton0 instance = new Singleton0();

    private Singleton0() {
    }

    public static Singleton0 getInstance() {
        return instance;
    }


    public static void main(String[] args) {

        for (int i = 0; i < 1000; i++) {
            new Thread(() -> {
                Singleton0 instance = Singleton0.getInstance();
                System.out.println("instance =  " + instance + "\n" + instance.hashCode());
            }).start();
        }
    }
}
